package acm.蓝桥5;

import java.util.Scanner;

public class 逐个求和 {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println(sum(sc.nextLine()));
    }
    public static String sum(String str){
        if (str.length()==1) return str;
        long sum=0;
        for (int i = 0; i < str.length(); i++) {
            sum+=str.charAt(i)-'0';
        }
        return sum(""+sum);
    }
}
